#!/usr/bin/python3
#Copyright Bail 2024
#old-phone-monitor:server 旧手机监视器服务端 v0.1_0
#2024.7.28


from flask import Flask,request
import os
app = Flask(__name__)

# -----以下为区块-----
PREFIX = '/old-phone-monitor'

def notify(msg:str):
    '''向手机发送通知
msg(str):要发送的通知'''
    os.system(f'termux-notification -c "{msg}"')
@app.route(PREFIX+'/heartbeat') # 心跳
def heartbeat():
    pass
@app.route(PREFIX+'/message_report')    # 报告消息
def message_report():
    msg = request.args.get('msg')
    notify(f'OPM: {msg}')
    return ''

# -----区快结束-----

if __name__ == '__main__':
    app.run()
